import store from  '../../utils/storageUtils'
import * as constants from '../actions/constants';
const  userinfo=store.getUser()||{}
const defaultState = {
        user: userinfo // 保存当前登陆的user
    }

export default (state = defaultState, action) => {
    switch(action.type) {
        case  constants.USER_LOGIN:
            return{
                ...state,
                user:action.userinfo,
            };
        case constants.RECEIVE_USER:
           return state;
        case constants.USER_OUT:
            return  {
                ...state,
                user:{}
            }
        default:
            return state;
    }
}
